﻿$('.selectpicker').selectpicker();

$("#deleteResourceBtn").click(function () {

    $(".seatResource").hide("drop", { direction: "left" }, 200);
    $(".deleteResource").show("drop", { direction: "right" }, 200);
    $("#addResourceBtn").hide("fade", 200);

});

$("#transferResourceBtn").click(function () {

    $(".seatResource").hide("drop", { direction: "left" }, 200);
    $(".transferResource").show("drop", { direction: "right" }, 200);
    $("#addResourceBtn").hide("fade", 200);


});

$("#addResourceBtn").click(function () {

    $(".seatResource").hide("drop", { direction: "left" }, 200);
    $(".addResource").show("drop", { direction: "right" }, 200);
    $("#addResourceBtn").hide("fade", 200);

});

$("#cancelDelBtn").click(function () {

    $(".deleteResource").hide("drop", { direction: "right" }, 200);
    $(".seatResource").show("drop", { direction: "left" }, 200);
    $("#addResourceBtn").show("fade", 200);

});

//Button for save movement
$("#saveMoveBtn").click(function () { 
    
});

//Got to transfer view
$("#confirmTransferBtn").click(function () {

    $(".transferResource").hide("drop", { direction: "right" }, 200);
    $(".seatResource").show("drop", { direction: "left" }, 200);
    $("#addResourceBtn").show("fade", 200);
    $("#destinationContainer").show("fade", 400);
    $("#editableContainer").hide("fade", 400);
    $(".seatManagerHome").hide("fade", 400);
    $(".seatManagerMovement").show("fade", 400);
    $('#seatManagerModal').modal('hide');

});

$("#cancelTransferBtn").click(function () {

    $(".transferResource").hide("drop", { direction: "right" }, 200);
    $(".seatResource").show("drop", { direction: "left" }, 200);
    $("#addResourceBtn").show("fade", 200);

});



$("#confirmAddBtn").click(function () {

    $(".addResource").hide("drop", { direction: "right" }, 200);

    $(".loading").show("fade");
    $('.progress').addClass('active');

    var progress = setInterval(function () {
        var $bar = $('.progress-bar');

        if ($bar.width() == 400) {
            clearInterval(progress);
            $('.progress').removeClass('active');
            $(".loading").hide("fade");
            $(".seatResource").show("drop", { direction: "left" }, 200);
            $("#addResourceBtn").show("fade", 200);

            $('.progress-bar').width(0);
            $bar.text("");
        } else {
            $bar.width($bar.width() + 40);
        }
        $bar.text($bar.width() / 4 + "%");

    }, 800);

});

$("#cancelAddBtn").click(function () {

    $(".addResource").hide("drop", { direction: "right" }, 200);
    $(".seatResource").show("drop", { direction: "left" }, 200);
    $("#addResourceBtn").show("fade", 200);
});


$('#editableContainer .seat').not('.post').click(function () {
    var seatCode = $(this).children('.seatCode').html();
    var resource = $(this).children('.resource').html();
    $('#seatManagerModal .modal-title').html(seatCode);
    $('#seatManagerModal .selectedResource').text(resource);
    $('#seatManagerModal').modal('show');
});



//events for clicking new seat assignment
$('#destinationContainer .seat').not('.post').click(function () {
    var seatCode = $(this).children('.seatCode').html();

    $('#seatCodeDestination').text(seatCode);
    $('#destinationContainer .seat').removeClass('chosenSeat');
    $(this).addClass('chosenSeat');

});


$("#saveMoveBtn").click(function () {

    $(".transferResource").hide("drop", { direction: "right" }, 200);
    $(".seatResource").show("drop", { direction: "left" }, 200);
    $("#addResourceBtn").show("fade", 200);
    $("#destinationContainer").hide("fade", 400);
    $("#editableContainer").show("fade", 400);
    $(".seatManagerHome").show("fade", 400);
    $(".seatManagerMovement").hide("fade", 400);
    $('#seatManagerModal').modal('show');

});

$("#cancelMoveBtn").click(function () {

    $(".transferResource").hide("drop", { direction: "right" }, 200);
    $(".seatResource").show("drop", { direction: "left" }, 200);
    $("#addResourceBtn").show("fade", 200);
    $("#destinationContainer").hide("fade", 400);
    $("#editableContainer").show("fade", 400);

    $(".seatManagerHome").show("fade", 400);
    $(".seatManagerMovement").hide("fade", 400);
    $('#seatManagerModal').modal('show');

});


$("#chooseLocationBtn").click(function () {

    $("#editableMapRow").show("drop", { direction: "right" }, 500);

});
